﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using M3G;

namespace MyTestProject {
    public class TestTraverse {
        /**
         * Ancestorsのテスト。Ancestorsは、
         *  - 自分自身を含む
         *  - シーングラフとボーン階層はシームレスに透過する
         *  */
        [Fact]
        public void TestAncestors () {
            var wld = new World ();
            var nod1 = new Group ();
            var skl  = new Group ();
            var msh = new SkinnedMesh (1, 0, skl);
            var bone = new Group ();
            wld.AddChild (nod1);
            nod1.AddChild (msh);
            skl.AddChild (bone);

            var nodes = bone.Ancestors;
            Assert.Equal (5, nodes.Length);
            Assert.Equal (bone, nodes[0]);
            Assert.Equal (skl, nodes[1]);
            Assert.Equal (msh, nodes[2]);
            Assert.Equal (nod1, nodes[3]);
            Assert.Equal (wld, nodes[4]);
        }

        /**
         * Descendantsのテスト。Descendantsは、
         *  - 自分自身を含む
         *  - シーングラフとボーン階層はシームレスに透過する
         *  */
        [Fact]
        public void TestDescendants () {
            var wld = new World ();
            var nod1 = new Group ();
            var skl  = new Group ();
            var msh = new SkinnedMesh (1, 0, skl);
            var bone = new Group ();
            wld.AddChild (nod1);
            nod1.AddChild (msh);
            skl.AddChild (bone);

            var nodes = wld.Descendants;
            Assert.Equal (5, nodes.Length);
            Assert.Equal (wld, nodes[0]);
            Assert.Equal (nod1, nodes[1]);
            Assert.Equal (msh, nodes[2]);
            Assert.Equal (skl, nodes[3]);
            Assert.Equal (bone, nodes[4]);
        }
    }
}
